package com.atguigu.factory;

import com.atguigu.pojo.Student;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.stereotype.Component;

/**
 * @version 1.0
 * @Author 马冰
 * @Date 2024/12/17 20:30
 * @注释
 */
@Component
public class StudentFactoryBean implements FactoryBean<Student> {

    //生产对象
    @Override
    public Student getObject() throws Exception {
        Student student = new Student();
        student.setId(1001);
        student.setName("张三");
        student.setAge(23);
        student.setGender("男");
        return student;
    }

    //设置对象的类型
    @Override
    public Class<?> getObjectType() {
        return Student.class;
    }

    //是否为单例
    @Override
    public boolean isSingleton() {
        return FactoryBean.super.isSingleton();
    }
}
